# -*- coding: utf-8 -*-
from common.helper import Helper
from db.mysql import MysqlClient
class Arrangement( object ):
    def __init__(self):
        self.mysql = MysqlClient()
        self.name = "少儿健康医疗保险"

    def pullData(self, data={}):
        for item in Helper.selectData(self.name, self.mysql):
            if item["contagionMedical"] == "0":
                contagionMedical = "0"
            elif  item["contagionMedical"] != "0" and len( item["contagionMedical"]) > 4:
                contagionMedical = str(int(int(item["contagionMedical"])/10000))+"w"
            else:
                contagionMedical = item["contagionMedical"]
            if item["hospitalMedical"] == "0":
                hospitalMedical = "0"
            elif item["hospitalMedical"] != "0" and len(item["hospitalMedical"]) > 4:
                hospitalMedical = str(int(int(item["hospitalMedical"]) / 10000)) + "w"
            else:
                hospitalMedical = item["hospitalMedical"]

            if item["specialMedical"] == "0":
                specialContagion = "0"
            elif item["specialMedical"] != "0" and len(item["specialMedical"]) > 4:
                specialContagion = str(int(int(item["specialMedical"]) / 10000)) + "w"
            else:
                specialContagion = item["specialMedical"]

            if item["accidentHospital"] == "0":
                accidentHospital = "0"
            elif item["accidentHospital"] != "0" and len(item["accidentHospital"]) > 4:
                accidentHospital = str(int(int(item["accidentHospital"]) / 10000)) + "w"
            else:
                accidentHospital = item["accidentHospital"]

            if item["accidentOutpatient"] == "0":
                accidentOutpatient = "0"
            elif item["accidentOutpatient"] != "0" and len(item["accidentOutpatient"]) > 4:
                accidentOutpatient = str(int(int(item["accidentOutpatient"]) / 10000)) + "w"
            else:
                accidentOutpatient = item["accidentOutpatient"]

            if item["accidentAllowance"] == "0":
                accidentAllowance = "0"
            elif item["accidentAllowance"] != "0" and len(item["accidentAllowance"]) > 4:
                accidentAllowance = str(int(int(item["accidentAllowance"]) / 10000)) + "w"
            else:
                accidentAllowance = item["accidentAllowance"]

            data["name"] = self.name
            data["company"] = "中国平安"
            data["year"] = item["year"]
            data["accidentDeath"] = str(int(int(item["accidentDeath"])/10000)) + "w"
            data["hospitalMedical"] = hospitalMedical
            data["contagionMedical"] = contagionMedical
            data["specialContagion"] = specialContagion
            data["accidentHospital"] = accidentHospital
            data["accidentOutpatient"] = accidentOutpatient
            data["accidentAllowance"] = accidentAllowance
            data["expire"] = "1年"
            data["payType"] ="年缴"
            data["price"] = item["price"]
            Helper.mergeTable(self.name, self.mysql, data)